<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>UI Switch</title>
</head>
<body>
  <fieldset>
    <legend>Day And Night</legend>
    <link href="day-and-night.css" rel="stylesheet">
    <div id="day-and-night">
      <div class="onOff daySwitch">
        <div class="star star1"></div>
        <div class="star star2"></div>
        <div class="star star3"></div>  
        <div class="star star4"></div>
        <div class="star star5"></div>
        <div class="star sky"></div>
        <div class="sunMoon">
            <div class="crater crater1"></div>
            <div class="crater crater2"></div>
            <div class="crater crater3"></div>
            <div class="cloud part1"></div>
            <div class="cloud part2"></div>
        </div>
    </div>
    </div>  
  </fieldset>

  <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
  <script>
    $('#day-and-night').on('click', function() {
      const $toggle = $('.onOff')
      $toggle.toggleClass('daySwitch')
    })
  </script>
</body>
</html>